﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Aspfm.Dal;
using Aspfm.Main;

namespace Aspfm.DataBase
{
    public partial class UcPassWord : UserControl
    {
        public UcPassWord()
        {
            InitializeComponent();

            dateTimePicker1.Format = DateTimePickerFormat.Custom;

            //dateTimePicker1的自定义格式 完整的是" yyyy-MM-dd HH:mm:ss"
            //或者dateTimePicker1.CustomFormat = "HH:mm"自定义即可
            dateTimePicker1.CustomFormat = "yyyy-MM-dd HH:mm";

            //时间控件上下输入值，也可以键盘键入
            dateTimePicker1.ShowUpDown = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string uno = textBox4.Text.Trim();
            string pwd = textBox5.Text.Trim();
            uno = uno.Trim().ToUpper();
            //pwd = MySecurity.SEncryptString("123", uno);

            if (!string.IsNullOrWhiteSpace(uno) && !string.IsNullOrWhiteSpace(pwd))
            {
                textBox3.Text = MySecurity.SDecryptString(pwd, uno);
            }
            else
            {
                MessageBox.Show("用户ID,密文均不允许为空");
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DateTime dt = dateTimePicker1.Value;
            int mm = dt.Minute/10;
            decimal str = Convert.ToDecimal(mm.ToString() + dt.ToString("ddyyyyMMHH"));
            decimal str1 = Convert.ToDecimal(dt.ToString("HHyyyyMMdd") + mm.ToString());
            decimal a = str - str1;
            if (str < str1)
            {
                a = str1 - str;
            }
            a = a / dt.Year/dt.Hour*dt.Month;
            textBox1.Text = Convert.ToString((int)a,16).ToString().ToUpper();
        }
    }
}
